package org.jeecg.modules.amazon.amazon.service.impl;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.amazon.amazon.entity.AmazonTask;
import org.jeecg.modules.amazon.amazon.mapper.AmazonTaskMapper;
import org.jeecg.modules.amazon.amazon.service.IAmazonTaskService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 亚马逊采集任务表
 * @Author: jeecg-boot
 * @Date:   2025-11-12
 * @Version: V1.0
 */
@Service
public class AmazonTaskServiceImpl extends ServiceImpl<AmazonTaskMapper, AmazonTask> implements IAmazonTaskService {

    /**
     * 查询任务
     * @return
     */
    @Override
    public List<AmazonTask> taskList(JSONObject jsonObject) {
        String user_id = jsonObject.getString("user_id");
        String gs_id = jsonObject.getString("gs_id");

        LambdaQueryWrapper<AmazonTask> amazonTaskLambdaQueryWrapper = new LambdaQueryWrapper<>();
        amazonTaskLambdaQueryWrapper.eq(AmazonTask::getTaskUserId,user_id);
        amazonTaskLambdaQueryWrapper.eq(StrUtil.isNotEmpty(gs_id),AmazonTask::getTaskGsId,gs_id);
        amazonTaskLambdaQueryWrapper.eq(AmazonTask::getTaskStatus,"1");
        List<AmazonTask> amazonTasks = this.baseMapper.selectList(amazonTaskLambdaQueryWrapper);
        return amazonTasks;
    }
}
